/**
 * 
 */
package com.mango.mstock.support;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

/**
 * @author richard
 *
 */
@Deprecated
public class _MStockPreference {
	
	private static _MStockPreference instance;
	private SharedPreferences preferences;
	
	public static _MStockPreference getInstance() {
		if (instance == null) {
			instance = new _MStockPreference();
			instance.preferences = MStockGlobalVars.getCurrentContext()
						.getSharedPreferences("Floating", Context.MODE_PRIVATE);
		}
		return instance;
	}
	
	private _MStockPreference(){}
	
	public void put(String key, Object obj) {
		if (obj == null) {
			throw new RuntimeException("should not store a null value");
		}
		
		Editor editor = preferences.edit();
		if (obj instanceof Float) {
			editor.putFloat(key, (Float) obj);
		} else {
			throw new RuntimeException("only support storing float for now");
		}
		editor.commit();
	}
	
	public float getFloat(String key) {
		return preferences.getFloat(key, 0f);
	}
	
}
